package com.qf.utils;

import com.qf.pojo.vo.Business;
import com.qf.pojo.vo.BusinessAndType;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class ListSort {
    //按距离降序
    public static List<Business> busDisJ(List<Business> logsList){
        Collections.sort(logsList, new Comparator<Business>() {
            @Override
            public int compare(Business o1, Business o2) {
                if ((o1.getDistance() > o2.getDistance())){
                    return 1;
                }
                if (o1.getDistance() == o2.getDistance()){
                    return 0;
                }
                return -1;
            }
        });
        return logsList;
    }
    //按距离升序
    public static List<Business> busDisS(List<Business> logsList){
        Collections.sort(logsList, new Comparator<Business>() {
            @Override
            public int compare(Business o1, Business o2) {
                if ((o1.getDistance() < o2.getDistance())){
                    return 1;
                }
                if (o1.getDistance() == o2.getDistance()){
                    return 0;
                }
                return -1;
            }
        });
        return logsList;
    }
    public static List<BusinessAndType> btDisJ(List<BusinessAndType> logsList){
        Collections.sort(logsList, new Comparator<BusinessAndType>() {
            @Override
            public int compare(BusinessAndType o1, BusinessAndType o2) {
                if ((o1.getDistance() > o2.getDistance())){
                    return 1;
                }
                if (o1.getDistance() == o2.getDistance()){
                    return 0;
                }
                return -1;
            }
        });
        return logsList;
    }
    //按距离降序
    public static List<BusinessAndType> btDisS(List<BusinessAndType> logsList){
        Collections.sort(logsList, new Comparator<BusinessAndType>() {
            @Override
            public int compare(BusinessAndType o1, BusinessAndType o2) {
                if ((o1.getDistance() < o2.getDistance())){
                    return 1;
                }
                if (o1.getDistance() == o2.getDistance()){
                    return 0;
                }
                return -1;
            }
        });
        return logsList;
    }
}
